{{ template "layout/header" .}}

<main id="body">
    <div class="container">
        <div class="row">
            <div class="col-lg-9 main">
                {{ template "layout/emailcheck" .}}
                <div class="card card-threadlist">
                    <div class="card-header">
                        <ul class="nav nav-tabs card-header-tabs">
                            <li class="nav-item">
                                <a class="nav-link active" href="/">最新</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link  " href="?index-0-1.htm">精华</a>
                            </li>
                        </ul>
                    </div>
                    <div class="card-body">
                        <ul class="list-unstyled threadlist mb-0">

                            {{$isadmin := .sessions.Isadmin}}
                            {{$sesid := .sessions.Userid}}
                            {{range .top_thread_list}}
                            <li class="media thread tap  " data-href="/thread/{{.ThreadID}}/detail.html" data-tid="22">
                                {{if eq $isadmin "1"}}
                                <input type="checkbox" name="modtid" class="mt-3 mr-2" value="{{.ThreadID}}">
                                {{end}}
                                <a href="{{if eq .Thread.User.ID $sesid}} /my.html {{else}}/user/{{.Thread.User.ID}}/info.html{{end}}"
                                    tabindex="-1" class="ml-1 mt-1 mr-3">
                                    <img class="avatar-3" src="{{.Thread.User.Avatar}}">
                                </a>
                                <div class="media-body">
                                    <div class="subject break-all font-weight-bold">
                                        <i class="icon-top-{{.Thread.Top}}"></i>
                                        <a href="/thread/{{.ThreadID}}/detail.html">{{.Thread.Subject}}</a>
                                        {{if .Thread.FilesNum}}
                                        <i class="icon small filetype other"></i>
                                        {{end}}
                                    </div>
                                    <div class="d-flex justify-content-between small mt-1">
                                        <div>
                                            <span class="username text-grey mr-1 "
                                                uid="1">{{.Thread.User.Username}}</span>
                                            <span class="date text-grey">{{.Thread.CreatedAt.Unix | strtime}}</span>
                                        </div>
                                        <div class="text-muted small">
                                            <span class="ml-2"><i class="icon-eye"></i> {{.Thread.ViewsCnt}}</span>
                                            <span class="ml-2"><i class="icon-comment-o"></i>
                                                {{.Thread.PostsCnt}}</span>
                                        </div>
                                    </div>
                                </div>
                            </li>
                            {{end}}


                            {{ range .threadList }}

                            <li class="media thread tap  " data-href="/thread/{{.ID}}/detail.html" data-tid="22">
                                {{if eq $isadmin "1"}}
                                <input type="checkbox" name="modtid" class="mt-3 mr-2" value="{{.ID}}">
                                {{end}}
                                <a href="{{if eq .User.ID $sesid}} /my.html {{else}}/user/{{.User.ID}}/info.html{{end}}"
                                    tabindex="-1" class="ml-1 mt-1 mr-3">
                                    <img class="avatar-3" src="{{.User.Avatar}}">
                                </a>
                                <div class="media-body">
                                    <div class="subject break-all font-weight-bold">
                                        <a href="/thread/{{.ID}}/detail.html">{{.Subject}}</a>
                                        {{if .FilesNum}}
                                        <i class="icon small filetype other"></i>
                                        {{end}}
                                    </div>
                                    <div class="d-flex justify-content-between small mt-1">
                                        <div>
                                            <span class="username text-grey mr-1 " uid="1">{{.User.Username}}</span>
                                            <span class="date text-grey">{{.CreatedAt.Unix | strtime}}</span>
                                        </div>
                                        <div class="text-muted small">
                                            <span class="ml-2"><i class="icon-eye"></i> {{.ViewsCnt}}</span>
                                            <span class="ml-2"><i class="icon-comment-o"></i> {{.PostsCnt}}</span>
                                        </div>
                                    </div>
                                </div>
                            </li>
                            {{end}}
                        </ul>
                    </div>
                </div>

                {{ template "mod/thread_list_mod.inc" .}}
                <nav class="my-3">
                    <ul class="pagination justify-content-center flex-wrap">
                        {{.pages | unescaped}}
                    </ul>
                </nav>
            </div>
            <div class="col-lg-3 d-none d-lg-block aside">
                {{ template "layout/addnewthread" .}}
                <div class="card card-site-info">
                    <div class="m-3">
                        <h5 class="text-center">{{.webname}}</h5>
                        <div class="small line-height-3">{{.description}}</div>
                    </div>
                    <div class="card-footer p-2">
                        <table class="w-100 small">
                            <tbody>
                                <tr align="center">
                                    <td>
                                        <span class="text-muted">主题数</span><br>
                                        <b>{{.threads_num}}</b>
                                    </td>
                                    <td>
                                        <span class="text-muted">帖子数</span><br>
                                        <b>{{.posts_num}}</b>
                                    </td>
                                    <td>
                                        <span class="text-muted">用户数</span><br>
                                        <b>{{.users_num}}</b>
                                    </td>
                                    <td>
                                        <span class="text-muted">在线</span><br>
                                        <b>{{.online}}</b>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="form-group">
                    <div id="search_form">
                        <div class="input-group mb-3">
                            <input type="text" class="form-control" placeholder="关键词" name="keyword">
                            <div class="input-group-append">
                                <button class="btn btn-primary" type="button" id="searchbutton">搜索</button>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="card card-newuser">
                    <div class="card-header text-grey">最新会员</div>
                    <div class="card-body small">
                        <div class="row">
                            {{range .newestuser}}
                            <div class="col-3 mb-1 text-center">
                                <a class="small text-muted text-nowrap" href="/user/{{.ID}}/info.html"
                                    data-toggle="tooltip" title="{{.Username}}" data-original-title="{{.Username}}">
                                    <img src="{{.Avatar}}" alt="{{.Username}}" width="28" height="28"
                                        class="img-circle"><br>{{.Username | substr}} </a>
                            </div>
                            {{end}}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</main>

{{/*{{.newestuser}}*/}}
<script>
    var jform = $('#search_form');
    var jsubmit = $('#searchbutton');

    jsubmit.on("click", function () {
        var jkeyword = jform.find('input[name="keyword"]').val();
        location.href = "/search.html?key=" + jkeyword
    })
</script>
{{ template "layout/footer" }}
